unit Basic;

interface

uses SysUtils, Windows, Classes;

const
  etFly=1;
  etWalk=2;
  etWater=4;
  etHot=8;
  etCold=16;
  etGhost=32;

  fEfemeric = 0;
  fFantom = 1;

  ltDarkness = 1;
  ltSunlight = 2;
  ltNeutral = 0;

type
  TBasic = class
    Name:String;
    ClassName:String;

    ImageFile:String;
    ImageIndex:Integer;
  end;

  TEntity = class(TBasic)
    Curse:Integer;

    Position:TPoint;
    Control:Integer;
    MovePoints,BaseMovePoints:Integer;
    Health,BaseHealth:Integer;
    Mana,BaseMana:Integer;
    Atack,Range:Integer;
    BaseAtack,BaseRange:Integer;
    Rodzaj, Flags, Light:Byte;
    constructor Create;
    procedure Update(Nr:Integer);
  end;

  TMagic = class(TBasic)
    MagicLevel:Integer;
    MagicType:Integer;
    ManaCost:Integer;
    Range:Integer;
  end;

  TSpell = class(TMagic)
    NeedsTarget, NeedsPos:Boolean;
    Trigger:procedure(Spell:TSpell; Control:Integer; TargetEnt:Integer=-1; X:Integer=-1; Y:Integer=-1);
    constructor Create(MLev, MTyp, MCost, Rnge,ImIn:Integer; Nm, ClNm,ImFi:String);
  end;

  TSummon = class(TMagic)
    Trigger:procedure(Summon:TSummon; Control:Integer; X,Y:Integer);
    constructor Create(MLev, MTyp, MCost, Rnge,ImIn:Integer; Nm, ClNm,ImFi:String);
  end;

var
  Entities:TList;
  AppExeName:String;
  Spells,Summons:TList;
  function GetFree(X,Y:Integer):Integer;

implementation

uses Unit1;

function GetFree(X,Y:Integer):Integer;
var C:Integer;
begin
  Result:=-1;
  For C:=0 to Entities.Count-1 do
  begin
    If (TEntity(Entities[C]).Position.X=X) and (TEntity(Entities[C]).Position.Y=Y) then
      Result:=C;
  end;
end;

constructor TEntity.Create;
begin
end;

constructor TSummon.Create(MLev, MTyp, MCost, Rnge,ImIn:Integer; Nm, ClNm,ImFi:String);
begin
  inherited Create;
  MagicLevel:=MLev;
  MagicType:=MTyp;
  ManaCost:=MCost;
  Range:=Rnge;
  Name:=Nm;
  ClassName:=ClNm;
  ImageIndex:=ImIn;
  ImageFile:=ImFi;
end;

constructor TSpell.Create(MLev, MTyp, MCost, Rnge,ImIn:Integer; Nm, ClNm,ImFi:String);
begin
  inherited Create;
  MagicLevel:=MLev;
  MagicType:=MTyp;
  ManaCost:=MCost;
  Range:=Rnge;
  Name:=Nm;
  ClassName:=ClNm;
  ImageIndex:=ImIn;
  ImageFile:=ImFi;
end;

procedure TEntity.Update(Nr:Integer);
var B:String;
begin
  B:='#U#'+IntToStr(Nr)+'#'+IntToStr(Nr)+'#XPOS#'+IntToStr(Position.X)+'#YPOS#'+IntToStr(Position.Y);
  B:=B+'#IMFI#'+ImageFile+'#IMIN#'+IntToStr(ImageIndex)+'#CURSE#'+IntToStr(Curse)+'#CTRL#'+IntToStr(Control);
  B:=B+'#MVP#'+IntToStr(MovePoints)+'#BMVP#'+IntToStr(BaseMovePoints)+'#MP#'+IntToStr(Mana)+'#BMP#'+IntToStr(BaseMana);
  B:=B+'#HP#'+IntToStr(Health)+'#BHP#'+IntToStr(BaseHealth)+'#ATAK#'+IntToStr(Atack)+'#RANGE#'+IntToStr(Range);
  B:=B+'#BATK#'+IntToStr(BaseAtack)+'#BRNG#'+IntToStr(BaseRange)+'#RODZAJ#'+IntToStr(Rodzaj)+'#FLAGS#'+IntToStr(Flags);
  B:=B+'#LIGHT#'+IntToStr(Light);
  B:=B+'#END#';
  MultiPlayer.Send(B);
end;

end.
